home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 9741 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.3 KB

  1. Path: mother.usf.edu!bilsby!millert
  2. From: Timothy Miller <millert@csee.usf.edu>
  3. Newsgroups: gnu.g++.help,comp.lang.c++
  4. Subject: HELP!: Optimizer problem ??
  5. Date: Sun, 3 Mar 1996 23:36:43 -0500
  6. Organization: University of South Florida
  7. Message-ID: <Pine.SUN.3.91.960303232330.17862A-100000@bilsby>
  8. NNTP-Posting-Host: bilsby.csee.usf.edu
  9. Mime-Version: 1.0
  10. Content-Type: TEXT/PLAIN; charset=US-ASCII
  11. X-Sender: millert@bilsby
  12.  
  13. I seem to be having a bit of a problem with g++.  This problem seems 
  14. rather odd to me, so I have put the complete source code to the project 
  15. I'm working on on the web at this address:
  16.  
  17. http://www.csee.usf.edu/~millert/temp/
  18.  
  19. (It's a senior project, so if you're interested, you can wait until it's 
  20. done and get complete working cleaned up source code to this ray tracer.)
  21.  
  22. Of particular interest are "sphere.cpp" and "matrix.hpp".  Look at line 
  23. 78 of sphere.cpp.  It says this:
  24.  
  25. n.el(3) = 0;
  26.  
  27. The code that it expands to is a member of my Matrix class that looks 
  28. like this:
  29.  
  30. double& el(int y, int x=0) { return v[x].el(y); }
  31.  
  32. The prolbem is that when I use the -O4 optimization setting (actually, 
  33. I've only tried it with -O4 and with no optimization), line 78 disappears 
  34. completely.  It is crucial to the algorythm, but it's never executed.  If 
  35. optimization is off, the line is executed properly.
  36.  
  37. If you download the code as it is and run it, it will produce a lot of 
  38. junk for output, but in that junk, you'll find that line 79 prints 
  39. n.el(3), but the value it prints is not zero.  I have tried using n.el(3, 
  40. 0), and it makes no difference.
  41.  
  42. Now, I'm not a good enough C++ programmer to feel that I have the right 
  43. to suspect a problem with the compiler, so I was wondering if some kind 
  44. soul out there could look at my code and see if there is something that 
  45. I'm doing wrong that lets it omit that line.
  46.  
  47. Also, since I'm new at this, I'm open to suggestions pertaining to my 
  48. programming style and programming approach.
  49.  
  50. Thanks.
  51.  
  52. ---------------------------------------------------------------------------
  53. Timothy Miller, millert@grad.csee.usf.edu           Theoretical Linguistics
  54. http://www.csee.usf.edu/~millert         Music Theory, Computer Engineering
  55. ---------------------------------------------------------------------------
  56. Cunning linguists are very skilled with their tongues.
  57.  
  58.